home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / telecomm / bbs / strek123.lha / StarTrek.rexx < prev   
Encoding:
OS/2 REXX Batch file  |  1994-04-11  |  30.5 KB  |  1,308 lines

  1. /* ***************************************************************
  2.    **                                                           **
  3.    **  STAR TREK - THE FINAL FRONTIER                           **
  4.    **                                                           **
  5.    **  Written by Steve Berry                                   **
  6.    **                                                           **
  7.    **  Rev A - 4/24/87 IBM 370                                  **
  8.    **                                                           **
  9.    **  Rev B - 5/21/88 modified to run on Amiga                 **
  10.    **                                                           **
  11.    **  Mods for Atredes by Bob Hassel and Michael Cox           **
  12.    **  ANSI version & other enhancements by Michael Cox         **
  13.    **                                                           **
  14.    **  Checks for dropped carrier & inactivity logoff.          **
  15.    **                                                           **
  16.    **  Change 'maxtime' to control maximum play time.           **
  17.    **                                                           **
  18.    **  10/02/91 -- Added UPPERcase conversion for the two       **
  19.    **              prompts-INSTRUCTIONS and LOAD OLD GAME       **
  20.    **              Syd L. Bolton, Legendary Design Tech. Inc.   **
  21.    **                                                           **
  22.    **  10/04/91 -- Fixed up logic problems when loading old     **
  23.    **              games (always had default energy & so on)    **
  24.    **              Made small cosmetic changes, added SAVE      **
  25.    **              option when quitting.                        **
  26.    **              Syd L. Bolton, Legendary Design Tech. Inc.   **
  27.    **                                                           **
  28.    **  12/28/91 -- Modified by James R. Graham of               **
  29.    **              The Portal Dolmen BBS (812)334-0418 to       **
  30.    **              work with TransAmiga BBS, version 1.1.       **
  31.    **                                                           **
  32.    **  04/09/94 -- Modified by Janne Siren (jts@krk.fi) of      **
  33.    **              Epsilon Indi BBS +358-0-505-4201 to work     **
  34.    **              with TechnoBBS. Several improvements:        **
  35.    **              - instructions in a separate file            **
  36.    **              - faster cursor movement using ANSI codes    **
  37.    **              - better outlook                             **
  38.    **              - optional IBM character graphics            **
  39.    **              - new command REDRAW                         **
  40.    **              - faster quadrant printing                   **
  41.    **              - better error checking                      **
  42.    **              - shooting a base will take 300 points       **
  43.    **              - mission completed bonus (500 points)       **
  44.    **              - a warp to the same quadrant is ignored     **
  45.    **              - optimizations (script 11k smaller)         **
  46.    **              - many bugs fixed                            **
  47.    **                                                           **
  48.    **  04/10/94 -- More accurate text centering and some        **
  49.    **              unnecessary redraws removed. Energy is       **
  50.    **              always displayed as an integer. Quadrant     **
  51.    **              printing is slightly faster. Collisions      **
  52.    **              are reported correctly. [JtS]                **
  53.    **                                                           **
  54.    **  04/10/94 -- Sets user status to 'Playing Star Trek'.     **
  55.    **              Faster quadrant printing. Color strip        **
  56.    **              warning. [JtS]                               **
  57.    **                                                           **
  58.    **  04/10/94 -- Login menu, user preferences and optional    **
  59.    **              screen bouncing when the Enterprise is hit.  **
  60.    **              Old saved games are not compatible! [JtS]    **
  61.    **                                                           **
  62.    **  TechnoBBS installation:                                  **
  63.    **                                                           **
  64.    **  - Move included files to Doors:StarTrek directory.       **
  65.    **  - Add following command to your menu and compile it.     **
  66.    **                                                           **
  67.    **  Command "TREK"                                           **
  68.    **  {                                                        **
  69.    **  dos("rx >NIL: Doors:StarTrek/StarTrek.rexx \(node())");  **
  70.    **  }                                                        **
  71.    **                                                           **
  72.    ***************************************************************
  73.  
  74.                                     $VER: Star Trek 1.23 (10.4.94)
  75. */
  76.  
  77.     Signal On IoErr ; Signal On Syntax
  78.  
  79.     maxtime = 2000
  80.  
  81.     CR    = D2C(13)
  82.     LF    = D2C(10)
  83.     CLS    = D2C(12)
  84.     CRLF    = CR||LF
  85.  
  86.     ln = Arg(1)
  87.  
  88.     LineName = Con_LineActive(ln)
  89.  
  90.     If LineName = "" Then Exit 10
  91.  
  92.     Address Command
  93.     Address Value LineName
  94.  
  95.     SetStatus "Playing Star Trek"
  96.  
  97.     uname = GetUserName(ln)
  98.  
  99.     highest = 0 ; highname = 0
  100.  
  101.     Call Time "R"
  102.  
  103.     Do I = 1 To 10
  104.         highscore.I = 0
  105.         highname.I = ""
  106.     End
  107.  
  108.     stardate = Time("E")
  109.  
  110.     ibm = 0 ; bounce = 0
  111.  
  112.     bar.0 = "--------------------------------------------------------------------------------"
  113.     bar.1 = "ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ"
  114.  
  115.     If GetStripAll(ln) Then Do
  116.         SendModem CLS||CRLF||"You need an ANSI-compatible terminal to play this game!"||CRLF||CRLF
  117.         Exit 0
  118.     End
  119.  
  120.     If GetStripCols(ln) Then Do
  121.         rs = GetYesNo(ln, CLS||CRLF||"Playing Star Trek without colors is not adviseable. Continue?", 0, 1)
  122.         If rs = 0 Then Do
  123.             SendModem CRLF||CRLF
  124.             Exit 0
  125.         End
  126.     End
  127.  
  128.     Call Old_Highest
  129.  
  130.     Call Load_Preferences
  131.  
  132.     SendModem CLS||CRLF||"CWelcome to Star Trek v1.23!"||CRLF||CRLF"CBrought to you by contributing authors:"||CRLF||CRLF||" Steve Berry, Bob Hassel, Michael Cox, Syd Bolton, James Graham and Janne Siren7HPress (RETURN) to continue: "
  133.  
  134.     GetHotkey(ln)
  135.  
  136.     quit = 0 ; saved = 0 ; alive = 1 ; mission = 1
  137.  
  138.     Call Redraw_Menu
  139.  
  140.     Do Until quit = 1
  141.         rs = Upper(GetHotkey(ln, "36HSelect: "))
  142.  
  143.         SendModem rs
  144.  
  145.         Select
  146.             When rs = "1" Then Do
  147.                 quit = 1
  148.             End
  149.  
  150.             When rs = "2" Then Do
  151.                 quit = 1
  152.                 saved = 1
  153.             End
  154.  
  155.             When rs = "3" Then Do
  156.                 Call Instructions 0
  157.                 Call Redraw_Menu
  158.             End
  159.  
  160.             When rs = "4" Then Do
  161.                 Call Display_Scores
  162.                 Call Redraw_Menu
  163.             End
  164.  
  165.             When rs = "5" Then Do
  166.                 Call Preferences
  167.                 Call Redraw_Menu
  168.             End
  169.  
  170.             When rs = "Q" Then Do
  171.                 SendModem CLS||CRLF
  172.                 Exit 0
  173.             End
  174.  
  175.             Otherwise Nop
  176.         End
  177.     End
  178.  
  179.     If saved = 1 Then Call Load_Old_Game
  180.  
  181.     Call Init_Variables_1
  182.  
  183. Start_Mission:
  184.  
  185.     starttime = stardate
  186.  
  187.     Call Redraw_Screen 1
  188.  
  189.     doprint = 1
  190.  
  191.     Do Until energy = 0
  192.  
  193.         If doprint = 1 Then Call Print_Quadrant
  194.  
  195.         doprint = 1
  196.  
  197.         t0 = Time("R")
  198.  
  199.         If stardate - starttime > maxtime Then Call Too_Long
  200.  
  201.         instring = Upper(AskInput(ln, "HCYour command, Captain? ", "", 20, "CAPITAL"))
  202.  
  203.         rc = Parse_Command(instring)
  204.  
  205.         If rc = 0 Then Do
  206.             Do loop = 1 To 3
  207.                 If arg1.loop = "" Then Leave
  208.                 Call Process_Command arg1.loop, arg2.loop
  209.                 If alive = 0 | energy <= 0 Then Leave
  210.             End
  211.         End
  212.         Else Do
  213.             SendModem CRLF||"CCommand not understood. Enter HELP for reminder."
  214.             GetHotkey(ln)
  215.         End
  216.  
  217.         If missstat = 1 Then Do
  218.             points = points + 500
  219.             SendModem CLS||CRLF||"Congratulations! You have completed the mission!"||CRLF||CRLF"You got "||points||" points. Play again soon!"||CRLF||CRLF
  220.             Call New_Highest
  221.             Exit 0
  222.         End
  223.  
  224.         If alive = 0 | energy <= 0 Then Do
  225.             SendModem CLS||CRLF||"Suicide is not in the best interests of the Federation."||CRLF||CRLF||"You got "||points||" points. Play again soon!"||CRLF||CRLF
  226.             Call New_Highest
  227.             Exit 0
  228.         End
  229.  
  230.         Call Wear_And_Tear
  231.  
  232.         If alive = 0 Then Do
  233.             SendModem CLS||CRLF||"Sorry, but you let the Enterprise detoriorate"||CRLF||"into a rusting hunk of space debris."||CRLF||CRLF||"You got "||points||" points. Play again soon!"||CRLF||CRLF
  234.             Call New_Highest
  235.             Exit 0
  236.         End
  237.  
  238.         Call Mission_1
  239.  
  240.         If alive = 0 Then Do
  241.             SendModem CLS||CRLF||"Sorry, but you let your crew and the Federation down."||CRLF||CRLF||"You got "||points||" points. Play again soon!"||CRLF||CRLF
  242.             Call New_Highest
  243.             Exit 0
  244.         End
  245.     End
  246.  
  247.     Exit 0
  248.  
  249. Load_Old_Game:
  250.  
  251.     missstat = 0
  252.  
  253.     LockCarrier
  254.  
  255.     If ~Open(fnn, "Doors:StarTrek/_"||uname||".dat", "R") Then UnLockCarrier
  256.     Else Do
  257.         Readln(fnn)
  258.  
  259.         inn = Readln(fnn)
  260.  
  261.         If inn ~= "" Then Do
  262.  
  263.             Parse Var inn stardate " " mission " " energy " " points " " x " " y " " ex " " ey " " shields " " klshields " " status.0 " " status.1 " " status.2 " " status.3 " " status.4 " " status.5 " " kltot " " docked
  264.  
  265.             stardate = stardate + Time("E")
  266.  
  267.             Do L = 0 To 9
  268.                 inn = Readln(fnn)
  269.                 Parse Var inn map.L.0 " " map.L.1 " " map.L.2 " " map.L.3 " " map.L.4 " " map.L.5 " " map.L.6 " " map.L.7 " " map.L.8 " " map.L.9
  270.             End
  271.  
  272.             Do L = 0 To 9
  273.                 inn = Readln(fnn)
  274.                 Parse Var inn quad.L.0 " " quad.L.1 " " quad.L.2 " " quad.L.3 " " quad.L.4 " " quad.L.5 " " quad.L.6 " " quad.L.7 " " quad.L.8 " " quad.L.9
  275.             End
  276.  
  277.             Close(fnn)
  278.  
  279.             UnLockCarrier
  280.  
  281.             Call Start_Mission
  282.         End
  283.     End
  284.  
  285.     Return
  286.  
  287. Init_Variables_1:
  288.  
  289.     energy = 1000000 ; x = 0 ; y = 0 ; points = 0 ; mission = 1
  290.     shields = 0 ; missstat = 0 ; kltot = 0 
  291.  
  292.     Do A = 0 To 9
  293.         Do B = 0 To 9
  294.             map.A.B = Random(0, 1) * 100 + Random(0, 1) * 10 + Random(0, 9)
  295.             If map.A.B > 99 Then kltot = kltot + 1
  296.         End
  297.     End
  298.  
  299.     klshields = 5000 ; status.0 = 0 ; status.1 = 0 ; status.2 = 0
  300.     status.3 = 0 ; status.4 = 0 ; status.5 = 0 ; ex = 5 ; ey = 4
  301.  
  302. New_Screen:
  303.  
  304.     enemies = map.x.y % 100
  305.     bases = (map.x.y - enemies * 100) % 10
  306.     stars = map.x.y - enemies * 100 - bases * 10
  307.  
  308.     Do I = 0 To 9
  309.         Do J = 0 To 9
  310.             quad.I.J = 0
  311.         End
  312.     End
  313.  
  314.     quad.ex.ey = 1
  315.  
  316.     Do A = 0 To stars - 1
  317.         rx = Random(0, 9)
  318.         ry = Random(0, 9)
  319.  
  320.         If quad.rx.ry = 0 Then quad.rx.ry = 2
  321.         Else A = A - 1
  322.     End
  323.  
  324.     If enemies ~= 0 Then Do
  325.         Do A = 0 To enemies - 1
  326.             rx = Random(0, 9)
  327.             ry = Random(0, 9)
  328.  
  329.             If quad.rx.ry = 0 Then quad.rx.ry = 3
  330.             Else A = A - 1
  331.         End
  332.     End
  333.  
  334.     If bases ~= 0 Then Do
  335.         Do A = 0 To bases - 1
  336.             rx = Random(0, 9)
  337.             ry = Random(0, 9)
  338.  
  339.             If quad.rx.ry = 0 Then quad.rx.ry = 4
  340.             Else A = A - 1
  341.         End
  342.     End
  343.  
  344.     docked = 0
  345.  
  346.     Return
  347.  
  348. Print_Quadrant:
  349.  
  350.     Call Dock?
  351.  
  352.     stardate = stardate + Time("E")
  353.  
  354.     If status.5 < 1 | docked = 1 Then astr = bstr
  355.     Else astr = "XXXIoIXXXXXXXXXXXXXXX"
  356.  
  357.     SendModem ""
  358.  
  359.     Do i0 = 0 To 9
  360.         line = ""||i0 + 6||";14H"
  361.  
  362.         Do j0 = 0 To 9
  363.             Select
  364.                 When quad.i0.j0 = 0 Then line = line||"   "
  365.                 When quad.i0.j0 = 1 Then line = line||""||"IoI"
  366.                 When quad.i0.j0 = 2 Then line = line||""||" * "
  367.                 When quad.i0.j0 = 3 Then line = line||""||"<->"
  368.                 When quad.i0.j0 = 4 Then line = line||""||"(B)"
  369.                 Otherwise Nop
  370.             End
  371.         End
  372.  
  373.         Select
  374.             When i0 = 0 Then line = line||"C"||stardate
  375.  
  376.             When i0 = 1 Then Do
  377.                 If energy > 10000 Then line = line||"C"||Left(energy % 1, 7)
  378.                 Else line = line||"C"||Left(energy % 1, 7)||""
  379.             End
  380.  
  381.             When i0 = 2 Then line = line||"C"||y||","||x
  382.             When i0 = 3 Then line = line||"C"||ex||","||ey
  383.             When i0 = 4 & docked = 1 Then line = line||"CDocked"
  384.             When i0 = 4 & map.x.y > 99 & docked = 0 Then line = line||"CRed   "
  385.             When i0 = 4 & map.x.y < 100 & docked = 0 Then line = line||"CGreen "
  386.  
  387.             When i0 = 5 Then Do
  388.                 If shields = 1 Then line = line||"CUp  "
  389.                 Else line = line||"CDown"
  390.             End
  391.  
  392.             When i0 = 8 Then line = line||"C"||Left(kltot, 2)
  393.             When i0 = 9 Then line = line||"C"||Left(points, 5)
  394.             Otherwise Nop
  395.         End
  396.  
  397.         SendModem line
  398.     End
  399.  
  400.     Return
  401.  
  402. Parse_Command:
  403.  
  404.     Parse Arg arg1.1 arg2.1 arg1.2 arg2.2 arg1.3 arg2.3
  405.  
  406.     comstr = "FIRTORPHASENRAILOWSHIWARIMPSAVQUIDRISTAHELPOWRED"
  407.  
  408.     If arg1.1 = "" Then Return 0
  409.  
  410.     Do I = 1 To 3
  411.         arg1.I = Left(arg1.I, 3)
  412.         arg2.I = Left(arg2.I, 3)
  413.  
  414.         If arg1.I = "" Then Leave
  415.  
  416.         Do J = 0 To 16
  417.             If arg1.I = SubStr(comstr, J * 3 + 1,3) Then Leave
  418.         End
  419.  
  420.         If J > 16  Then Return -1
  421.         If arg2.I = "" Then Return 0
  422.  
  423.         Do J = 0 To 16
  424.             If arg2.I = SubStr(comstr, J * 3 + 1,3) Then Leave
  425.         End
  426.  
  427.         If J > 16 Then Return -1
  428.     End
  429.  
  430.     Return 0
  431.  
  432. Process_Command:
  433.  
  434.     Arg word1, word2
  435.  
  436.     Select
  437.         When word1 = "FIR" Then Call Weapon_Control word2
  438.         When word1 = "SEN" Then Call Sensors
  439.         When word2 = "SHI" Then Call Shield_Control word1
  440.         When word2 = "DRI" Then Call Engine_Control word1
  441.         When word2 = "POW" Then Call Engine_Control word1
  442.         When word1 = "HEL" Then Call Instructions 1
  443.         When word1 = "SAV" Then Call Save_Game
  444.         When word1 = "STA" Then Call Display_Info
  445.  
  446.         When word1 = "RED" Then Do
  447.             Call Redraw_Screen 0
  448.         End
  449.  
  450.         When word1 = "QUI" Then Do
  451.             If GetYesNo(ln, "HCQuit: Save the game in progress?", 1, 1) Then Call Save_Game
  452.             SendModem CLS||CRLF
  453.             Exit 0
  454.         End
  455.  
  456.         Otherwise Nop
  457.     End
  458.  
  459.     Return
  460.  
  461. Weapon_Control:
  462.  
  463.     Arg weapon
  464.  
  465.     If (weapon ~= "PHA") & (weapon ~= "TOR") Then Do
  466.         SendModem "HCI am confused by that order, Captain."
  467.         GetHotkey(ln)
  468.         Return
  469.     End
  470.  
  471.     If weapon = "PHA" Then Do
  472.         If map.x.y < 100 Then Do
  473.             SendModem "HCNo targets!"
  474.             GetHotkey(ln)
  475.             Return
  476.         End
  477.  
  478.         kx = 0
  479.         ky = 0
  480.  
  481.         Do I = 0 To 9
  482.             Do J = 0 To 9
  483.                 If quad.I.J = 3 Then Do
  484.                     kx = I
  485.                     ky = J
  486.                 End
  487.             End
  488.         End
  489.  
  490.         distance = ((ex - kx) * * 2 + (ey - ky) * * 2)
  491.  
  492.         Do I = 1 To 13 By .5
  493.             t0 = distance / I
  494.             If t0 < I Then Leave
  495.         End
  496.  
  497.         distance = I
  498.         energy = energy - 5000
  499.         hit = (1 - status.1) * 5000 - (distance * 500)
  500.  
  501.         If hit < 0 Then hit = 0
  502.  
  503.         klshields = klshields - hit
  504.  
  505.         SendModem "HCPhasers locked on target! Phasers fired!"
  506.  
  507.         If klshields <= 0 Then Do
  508.             string = "Klingon hit with "||hit % 1||" units of energy! Klingon Destroyed!"
  509.             SendModem ""||(81 - Length(string)) % 2||"H"||string
  510.             points = points + 50
  511.             klshields = 5000
  512.             quad.kx.ky = 0
  513.             map.x.y = map.x.y - 100
  514.             kltot = kltot - 1
  515.         End
  516.         Else Do
  517.             string = "Klingon hit with "||hit % 1||" units of energy! Still alive!"
  518.             SendModem ""||(81 - Length(string)) % 2||"H"||string
  519.         End
  520.  
  521.         GetHotkey(ln)
  522.     End
  523.     Else Do
  524.         Do Until C = 0
  525.             dy = AskInput(ln, "13HX vector, Captain (-1 = left, 0 = middle, 1 = right)? ", "", 3)
  526.             dx = AskInput(ln, "13HY vector, Captain (-1 = up, 0 = middle, 1 = down)? ", "", 3)
  527.  
  528.             If dx = "" Then dx = 0
  529.             If dy = "" Then dy = 0
  530.  
  531.             If (dx = -1 | dx = 0 | dx = 1) & (dy = -1 | dy = 0 | dy = 1) Then C = 0
  532.             Else C = 1
  533.         End
  534.  
  535.         tx = ex
  536.         ty = ey
  537.  
  538.         Do lp = 0 To 9
  539.             t0 = tx+dx
  540.             t1 = ty+dy
  541.  
  542.             If (t0 < 0) | (t0 > 9) | (t1 < 0) | (t1 > 9) Then Do
  543.                 SendModem "HCTorpedo missed!"
  544.                 GetHotkey(ln)
  545.                 Return
  546.             End
  547.  
  548.             space = quad.t0.t1
  549.  
  550.             If space ~= 0 Then
  551.                 Select
  552.                     When space = 2 Then Do
  553.                         SendModem "HCTorpedo hits a star!"
  554.                         GetHotkey(ln)
  555.                         Return
  556.                     End
  557.  
  558.                     When space = 3 Then Do
  559.                         SendModem "HCTorpedo hits a Klingon! Enemy ship destroyed! Good shot, Captain!"
  560.                         GetHotkey(ln)
  561.                         quad.t0.t1 = 0
  562.                         map.x.y = map.x.y - 100
  563.                         kltot = kltot - 1
  564.                         points = points + 100
  565.                         Return
  566.                     End
  567.  
  568.                     When space = 4 Then Do
  569.                         SendModem "HCTorpedo hits a base! Court martial is imminent!"
  570.                         GetHotkey(ln)
  571.                         If points >= 300 Then points = points - 300
  572.                         Else points = 0
  573.                         Return
  574.                     End
  575.  
  576.                     Otherwise Do
  577.                         SendModem "HCTorpedo hits the deathstar! Torpedo seems to have no effect!"
  578.                         GetHotkey(ln)
  579.                         Return
  580.                     End
  581.                 End
  582.  
  583.             quad.t0.t1 = 6
  584.             tx = t0
  585.             ty = t1
  586.             quad.tx.ty = 0
  587.         End
  588.     End
  589.  
  590.     Return
  591.  
  592. Wear_And_Tear:
  593.  
  594.     If alive = 0 Then Return
  595.  
  596.     pick = Random(0, 5)
  597.  
  598.     If docked = 1 Then
  599.         If status.pick = 0 Then Return
  600.         Else status.pick = status.pick - .1
  601.     Else Do
  602.         If status.pick < 1 Then Do
  603.             status.pick = status.pick + .1
  604.  
  605.             If status.pick = 1 Then Do
  606.                 SendModem "HCStatus Report:"||CRLF||CRLF
  607.  
  608.                 Select
  609.                     When pick = 0 Then SendModem "CComputer is in need of repair!"
  610.                     When pick = 1 Then SendModem "CPhasers are in need of repair!"
  611.                     When pick = 2 Then SendModem "CTorpedos are in need of repair!"
  612.                     When pick = 3 Then SendModem "CWarp drive is in need of repair!"
  613.                     When pick = 4 Then SendModem "CImpulse drive is in need of repair!"
  614.                     When pick = 5 Then SendModem "CSensors are out of order!"
  615.                 End
  616.  
  617.                 If status.3 > .9 & status.4 > .9 Then Do
  618.                     SendModem "3HSir, we seem to be dead in space! The warp and the impulse drive are out!"
  619.                     alive = 0
  620.                 End
  621.  
  622.                 GetHotkey(ln)
  623.                 doprint = 1
  624.             End
  625.         End
  626.     End
  627.  
  628.     Return
  629.  
  630. Engine_Control:
  631.  
  632.     Arg power
  633.  
  634.     If power = "WAR" Then Do
  635.         If status.3 > 1.2 Then Do
  636.             SendModem "HCSorry Captain, warp drive is out of commission!"
  637.             GetHotkey(ln)
  638.             Return
  639.         End
  640.  
  641.         dy = AskInput(ln, "HCDestination X coordinate (0-9)? ", "", 2, "NUMERIC")
  642.         dx = AskInput(ln, "14HDestination Y coordinate (0-9)? ", "", 2, "NUMERIC")
  643.  
  644.         If dx = y & dy = x Then Return
  645.  
  646.         If dx = "" Then dx = 0
  647.         If dy = "" Then dy = 0
  648.  
  649.         If x > 9 | y < 0 | x  < 0 | y > 9 Then Do
  650.             energy = energy - 5000
  651.             SendModem "HCCaptain, the warp drive is in a bad way and we are losing energy fast!"
  652.             GetHotkey(ln)
  653.         End
  654.  
  655.         energy = energy - ((((dx - x) * * 2 + (dy - y) * * 2) / 2.5) * 1000 + status.3 * 5000)
  656.  
  657.         If shields = 0 Then Do
  658.             If bounce = 1 Then SendModem "ST"
  659.             SendModem "H Shields are down! The Enterprise is caught in the void of intergalatic space!6HDamage Report: Warp drive damaged, impulse drive damaged, sensors out!"
  660.             GetHotkey(ln)
  661.             status.3 = status.3 + 1
  662.             status.4 = status.4 + 1
  663.             status.5 = 1.1
  664.         End
  665.         Else energy = energy - 5000
  666.  
  667.         x = dx
  668.         y = dy
  669.  
  670.         If x > -1 & x < 10 & y > -1 & y < 10 Then Do
  671.             doprint = 0
  672.             Call New_Screen
  673.             Call Print_Quadrant
  674.         End
  675.     End
  676.     Else Do
  677.         If power ~= "IMP" Then Return
  678.  
  679.         If status.4 > .9 Then Do
  680.             SendModem "HCSorry Captain, impulse drive is out of commission!"
  681.             GetHotkey(ln)
  682.             Return
  683.         End
  684.  
  685.         factor = AskInput(ln, "14HWhat impulse factor, Captain? ", "", 2, "NUMERIC")
  686.  
  687.         If factor = "" Then factor = 0
  688.  
  689.         Do Until C = 0
  690.             dy = AskInput(ln, "13HX vector, Captain (-1 = left, 0 = middle, 1 = right)? ", "", 3)
  691.             dx = AskInput(ln, "13HY vector, Captain (-1 = up, 0 = middle, 1 = down)? ", "", 3)
  692.  
  693.             If dx = "" Then dx = 0
  694.             If dy = "" Then dy = 0
  695.  
  696.             If (dx = -1 | dx = 0 | dx = 1) & (dy = -1 | dy = 0 | dy = 1) Then C = 0
  697.             Else C = 1
  698.         End
  699.  
  700.         Do I = 0 To factor - 1
  701.             If ((ex + dx) < 0) | ((ex + dx) > 9) | ((ey + dy) < 0) |((ey + dy) > 9) Then Do
  702.                 SendModem "HCYou have to use the warp drive to exit the quadrant."
  703.                 GetHotkey(ln)
  704.                 Return
  705.             End
  706.  
  707.             t0 = ex + dx
  708.             t1 = ey + dy
  709.  
  710.             space = quad.t0.t1
  711.  
  712.             If space ~= 0 Then Do
  713.                 Select
  714.                     When space = 2 Then Do
  715.                         SendModem "HCCollission with a star!"
  716.                         alive = 0
  717.                     End
  718.  
  719.                     When space = 3 Then Do
  720.                         SendModem "HCCollission with a Klingon!"
  721.                         alive = 0
  722.                     End
  723.  
  724.                     When space = 4 Then Do
  725.                         SendModem "HCCollission with a base!"
  726.                         alive = 0
  727.                     End
  728.  
  729.                     Otherwise Do
  730.                         SendModem "HCSwallowed by the deathstar!"
  731.                         alive = 0
  732.                     End
  733.                 End
  734.  
  735.                 I = factor - 1
  736.  
  737.                 GetHotkey(ln)
  738.             End
  739.  
  740.             quad.ex.ey = 0
  741.             quad.t0.t1 = 1
  742.             ex = t0
  743.             ey = t1
  744.         End
  745.  
  746.         If alive = 1 & factor > 0 Then Do
  747.             doprint = 0
  748.             Call Print_Quadrant
  749.         End
  750.     End
  751.  
  752.     Return
  753.  
  754. Dock?:
  755.  
  756.     docked = 0
  757.  
  758.     Do i1 = -1 To 1
  759.         Do j1 = -1 To 1
  760.             If i1+ex > -1 & i1+ex < 10 & j1+ey > -1 & j1+ey < 10 Then Do
  761.                 ta = i1+ex
  762.                 tb = j1+ey
  763.  
  764.                 If quad.ta.tb = 4 Then Do
  765.                     docked = 1
  766.                     t = status.0 + status.1 + status.2 + status.3 + status.4 + status.5
  767.                     stardate = stardate + t
  768.                     status.0 = 0
  769.                     status.1 = 0
  770.                     status.2 = 0
  771.                     status.3 = 0
  772.                     status.4 = 0
  773.                     status.5 = 0
  774.                 End
  775.             End
  776.         End
  777.     End
  778.  
  779.     If kltot = 0 Then missstat = 1
  780.  
  781.     Return
  782.  
  783. Save_Game:
  784.  
  785.     missstat = 0
  786.  
  787.     LockCarrier
  788.  
  789.     If ~Open(fnn, "Doors:StarTrek/_"||uname||".dat", "W") Then Do
  790.         UnLockCarrier
  791.         SendModem "HCError: Unable to open save file! Try again!"
  792.         GetHotkey(ln)
  793.         Return
  794.     End
  795.  
  796.     SendModem "HCStoring your game..."
  797.  
  798.     Writeln(fnn, ibm bounce||Left(" ", 60))
  799.  
  800.     Writeln(fnn, stardate mission energy points x y ex ey shields klshields status.0 status.1 status.2 status.3 status.4 status.5 kltot docked)
  801.  
  802.     Do L = 0 To 9
  803.         Writeln(fnn, map.L.0 map.L.1 map.L.2 map.L.3 map.L.4 map.L.5 map.L.6 map.L.7 map.L.8 map.L.9)
  804.     End
  805.  
  806.     Do L = 0 To 9
  807.         Writeln(fnn, quad.L.0 quad.L.1 quad.L.2 quad.L.3 quad.L.4 quad.L.5 quad.L.6 quad.L.7 quad.L.8 quad.L.9)
  808.     End
  809.  
  810.     Close(fnn)
  811.  
  812.     UnLockCarrier
  813.  
  814.     Return
  815.  
  816. Sensors:
  817.  
  818.     If status.5 < 1.1 Then Do
  819.  
  820.         If ibm = 1 Then Do
  821.             SendModem "49HÚÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄ¿"
  822.             br = " ³ "
  823.         End
  824.         Else Do
  825.             SendModem "49H-------------------"
  826.             br = "   "
  827.         End
  828.  
  829.         P = 0
  830.  
  831.         Do I = -1 To 1
  832.             P = P + 1
  833.  
  834.             If I ~= -1 Then Do
  835.                 If ibm = 1 Then SendModem ""||12 + P||";48H ÃÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄ´ "
  836.                 Else SendModem ""||12 + P||";48H ------------------- "
  837.             End
  838.  
  839.             P = P + 1
  840.  
  841.             line = ""||12 + P||";48H"||br
  842.  
  843.             Do J = -1 To 1
  844.                 t0 = x + I
  845.                 t1 = y + J
  846.                 If t0 < 0 | t0 > 9 | t1 < 0 | t1 > 9 Then line = line||"XXX"||br
  847.                 Else Do
  848.                     If map.t0.t1 < 100 & map.t0.t1 > 9 Then line = line||" "
  849.                     If map.t0.t1 < 10 Then line = line||"  "
  850.  
  851.                     line = line||map.t0.t1||br
  852.                 End
  853.             End
  854.  
  855.             SendModem line
  856.         End
  857.  
  858.         If ibm = 1 Then SendModem "49HÀÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÙ"
  859.         Else SendModem "49H-------------------"
  860.  
  861.         GetHotkey(ln);
  862.  
  863.         If ibm = 1 Then SendModem "49H                   "
  864.         Else SendModem "49H"
  865.  
  866.         SendModem "49HKlingons:  "||Left(kltot, 8)||"49HScore:     "||Left(points, 8)
  867.  
  868.         If ibm = 1 Then SendModem "49H                   48HÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;"
  869.         Else SendModem "49H48H======================"
  870.     End
  871.     Else Do
  872.         SendModem "HCLong-range sensors are out, Captain!"
  873.         GetHotkey(ln);
  874.     End
  875.  
  876.     Return
  877.  
  878. Shield_Control:
  879.  
  880.     Arg direction
  881.  
  882.     If direction = "RAI" Then
  883.         If shields = 1 Then Do
  884.             SendModem "HCShields are already up!"
  885.         End
  886.         Else Do
  887.             shields = 1
  888.             SendModem "HCShields up, Captain."
  889.             energy = energy - 3000
  890.         End
  891.     Else
  892.         If direction = "LOW" Then
  893.             If shields = 0 Then Do
  894.                 SendModem "HCShields are already down!"
  895.             End
  896.             Else Do
  897.                 shields = 0
  898.                 SendModem "HCShields down, Captain."
  899.                 energy = energy + 3000
  900.             End
  901.             Else SendModem "HCI am confused by that order, Captain."
  902.  
  903.     GetHotkey(ln)
  904.     Return
  905.  
  906. Display_Info:
  907.  
  908.     title = "Status report for Enterprise - Stardate "||stardate
  909.  
  910.     SendModem CLS||CRLF||title||CRLF||""||Left(bar.ibm, Length(title))||""||CRLF
  911.     c = 100 - status.0 * 100
  912.     SendModem "Computer"||Length(title) - Length(c) - 9||"C"||c||"%"||CRLF
  913.     c = 100 - status.1 * 100
  914.     SendModem "Phasers"||Length(title) - Length(c) - 8||"C"||c||"%"||CRLF
  915.     c = 100 - status.2 * 100
  916.     SendModem "Torpedos"||Length(title) - Length(c) - 9||"C"||c||"%"||CRLF
  917.     c = 100 - status.3 * 100
  918.     SendModem "Warp drive"||Length(title) - Length(c) - 11||"C"||c||"%"||CRLF
  919.     c = 100 - status.4 * 100
  920.     SendModem "Impulse drive"||Length(title) - Length(c) - 14||"C"||c||"%"||CRLF
  921.     c = 100 - status.5 * 100
  922.     SendModem "Sensors"||Length(title) - Length(c) - 8||"C"||c||"%"||CRLF||CRLF
  923.  
  924.     Call Hit_Return
  925.     Call Redraw_Screen 0
  926.  
  927.     Return
  928.  
  929. Instructions:
  930.  
  931.     Arg game
  932.  
  933.     SendASCII "Doors:StarTrek/Instructions.txt"
  934.     Call Hit_Return
  935.  
  936.     If game = 1 Then Call Redraw_Screen 0
  937.  
  938.     Return
  939.  
  940. Hit_Return:
  941.  
  942.     GetHotkey(ln, "Hit (RETURN) to continue: ");
  943.     Return
  944.  
  945. Mission_1:
  946.  
  947.     If map.x.y > 99 Then Do
  948.         Do I = 0 To 9
  949.             Do J = 0 To 9
  950.                 If quad.I.J = 3 Then Do
  951.                     tx = I
  952.                     ty = J
  953.                 End
  954.             End
  955.         End
  956.  
  957.         If tx > ex Then t0 = -1
  958.         If tx = ex Then t0 = 0
  959.         If tx < ex Then t0 = 1
  960.         If ty > ey Then t1 = -1
  961.         If ty = ey Then t1 = 0
  962.         If ty < ey Then t1 = 1
  963.  
  964.         factor = ((tx - ex) * * 2 + (ty - ey) * * 2)
  965.  
  966.         Do I = 1 To 13 By .5
  967.             tm = factor / I
  968.             If tm < I Then Leave
  969.         End
  970.  
  971.         factor = I % 1
  972.  
  973.         kl = 1 ; iskl = 1
  974.  
  975.         Do I = 0 To factor - 1
  976.             If factor < 1 Then Leave
  977.  
  978.             t2 = tx + t0
  979.             t3 = ty + t1
  980.  
  981.             If t2 < 0 | t2 > 9 | t3 < 0 | t3 > 9 Then Leave
  982.  
  983.             space = quad.t2.t3
  984.  
  985.             If space = 1 Then Leave
  986.  
  987.             If space ~= 0 & kl = 1 Then DO
  988.                 doprint = 1
  989.  
  990.                 Select
  991.                     When space = 2 Then Do
  992.                         SendModem "HCKlingon collides with a star!"
  993.                         GetHotkey(ln)
  994.                         quad.tx.ty = 0
  995.                         map.x.y = map.x.y - 100
  996.                         kltot = kltot - 1
  997.                         kl = 0
  998.                     End
  999.  
  1000.                     When space = 3 Then Do
  1001.                         SendModem "HCKlingon collides with a Klingon!"
  1002.                         GetHotkey(ln)
  1003.                         quad.tx.ty = 0
  1004.                         quad.t2.t3 = 0
  1005.                         map.x.y = map.x.y - 200
  1006.                         kltot = kltot - 2
  1007.                         kl = 0
  1008.                     End
  1009.  
  1010.                     When space = 4 Then Do
  1011.                         SendModem "HCKlingon collides with a base!"
  1012.                         GetHotkey(ln)
  1013.                         quad.tx.ty = 0
  1014.                         quad.t2.t3 = 0
  1015.                         map.x.y = map.x.y - 100
  1016.                         kltot = kltot - 1
  1017.                         kl = 0
  1018.                     End
  1019.  
  1020.                     Otherwise Do
  1021.                         SendModem "HCKlingon swallowed by the deathstar!"
  1022.                         GetHotkey(ln)
  1023.                         points = points + 50
  1024.                         quad.tx.ty = 0
  1025.                         map.x.y = map.x.y - 100
  1026.                         kltot = kltot - 1
  1027.                         kl = 0
  1028.                     End
  1029.                 End
  1030.  
  1031.                 If kl = 1 Then Do
  1032.                     quad.tx.ty = 0
  1033.                     quad.t2.t3 = 3
  1034.                     tx = t2
  1035.                     ty = t3
  1036.                 End
  1037.             End
  1038.         End
  1039.  
  1040.         If docked = 1 Then Return
  1041.  
  1042.         If kl = 1 Then Do
  1043.             amount = klshields / 5000 * Random(100, 500) * 10
  1044.  
  1045.             If bounce = 1 Then SendModem "ST"
  1046.  
  1047.             If amount > 1000 & shields = 0 Then Do
  1048.                 SendModem "HCKlingon fires phasers! Enterprise shields are down!9HEnterprise hit with "||amount||" units of energy! Enterprise destroyed!"
  1049.                 GetHotkey(ln)
  1050.                 doprint = 1
  1051.                 alive = 0
  1052.             End
  1053.  
  1054.             If amount < 3000 & shields = 1 Then Do
  1055.                 SendModem "HCKlingon fires phasers! Enterprise shields are up!24HShields absorb impact! No damage!"
  1056.                 GetHotkey(ln)
  1057.                 doprint = 1
  1058.                 energy = energy - amount
  1059.             End
  1060.  
  1061.             If amount > 3000 & shields = 1 Then Do
  1062.                 string = "Enterprise hit with "||amount % 1||" units of energy!"
  1063.                 SendModem "HCKlingon fires phasers! Enterprise shields are up!"||(81 - Length(string)) % 2||"H"||string
  1064.                 GetHotkey(ln)
  1065.                 doprint = 1
  1066.                 energy = energy - amount
  1067.  
  1068.                 Do I = 0 To (amount - 3000) / 100
  1069.                     Call Wear_And_Tear
  1070.                 End
  1071.             End
  1072.  
  1073.             If amount < 1001 & shields = 0 Then Do
  1074.                 string = "Enterprise hit with "||amount % 1||" units of energy!"
  1075.                 SendModem "HCKlingon fires phasers! Enterprise shields are down!"||(81 - Length(string)) % 2||"H"||string
  1076.                 GetHotkey(ln)
  1077.                 doprint = 1
  1078.  
  1079.                 Do I = 0 To amount / 100
  1080.                     Call Wear_And_Tear
  1081.                 End
  1082.             End
  1083.         End
  1084.     End
  1085.  
  1086.     If map.x.y < 299 & alive = 1 Then Do
  1087.         found = 0
  1088.  
  1089.         Do I = -1 To 1
  1090.             Do J = -1 To 1
  1091.                 tx = I + x
  1092.                 ty = J + y
  1093.  
  1094.                 If (tx > -1) & (tx < 10) & (ty > -1) & (ty < 10) Then Do
  1095.                     If (map.tx.ty > 99) & ((i ~=0 )|(j ~=0 )) Then Do
  1096.                         found = 1
  1097.                         I = 1
  1098.                         J = 1
  1099.                     End
  1100.                 End
  1101.             End
  1102.         End
  1103.  
  1104.         If found = 1 Then Do
  1105.             SendModem "HCCaptain! A Klingon warship has just warped into the quadrant!"
  1106.             GetHotkey(ln)
  1107.             doprint = 1
  1108.  
  1109.             map.tx.ty = map.tx.ty - 100
  1110.             map.x.y = map.x.y + 100
  1111.  
  1112.             Do Until A = 1
  1113.                 rx = Random(0,9)
  1114.                 ry = Random(0,9)
  1115.  
  1116.                 If quad.rx.ry = 0 Then Do
  1117.                     quad.rx.ry = 3
  1118.                     A = 1
  1119.                 End
  1120.                 Else A = 0
  1121.             End
  1122.         End
  1123.     End
  1124.  
  1125.     If kltot = 0 Then missstat = 1
  1126.  
  1127.     Return
  1128.  
  1129. Old_Highest:
  1130.  
  1131.     LockCarrier
  1132.  
  1133.     If ~Open(fnn, "Doors:StarTrek/Highscore.dat", "R") Then DO
  1134.         UnLockCarrier
  1135.         Return
  1136.     End
  1137.  
  1138.     Do I=1 To 10
  1139.         highname.i = Readln(fnn)
  1140.         highscore.i = Readln(fnn)
  1141.     End
  1142.  
  1143.     Close(fnn)
  1144.  
  1145.     UnLockCarrier
  1146.  
  1147.     Return
  1148.  
  1149. New_Highest:
  1150.  
  1151.     If uname = "" Then Return
  1152.  
  1153.     If points <= highscore.10 Then Return
  1154.  
  1155.     SendModem "You are in the top ten! Saving your name and score for posterity..."
  1156.  
  1157.     highscore.10 = points
  1158.     highname.10 = uname
  1159.  
  1160.     Do Forever
  1161.         changes = 0
  1162.  
  1163.         Do i = 1 To 9
  1164.             ih = i + 1
  1165.  
  1166.             If highscore.ih > highscore.i Then Do
  1167.                 temp = highscore.i
  1168.                 tempname = highname.i
  1169.                 highscore.i = highscore.ih
  1170.                 highname.i = highname.ih
  1171.                 highscore.ih = temp
  1172.                 highname.ih = tempname
  1173.                 changes = 1
  1174.             End
  1175.         End
  1176.  
  1177.         If changes = 0 Then Leave
  1178.     End
  1179.  
  1180.     LockCarrier
  1181.  
  1182.     If ~Open(fnn, "Doors:StarTrek/Highscore.dat", "W") Then Do
  1183.         UnLockCarrier
  1184.         Return
  1185.     End
  1186.  
  1187.     Do i = 1 To 10
  1188.         If Writeln(fnn, highname.i) < 1 Then Return
  1189.         If Writeln(fnn, highscore.i) < 1 Then Return
  1190.     End
  1191.  
  1192.     Close(fnn)
  1193.  
  1194.     UnLockCarrier
  1195.  
  1196.     SendModem CRLF||CRLF
  1197.  
  1198.     Return
  1199.  
  1200. Too_Long:
  1201.  
  1202.     SendModem "HCSorry, time up for this round!"
  1203.  
  1204.     If GetYesNo(ln, "20HQuit: Save the game in progress?", 1, 1) Then Call Save_Game
  1205.     SendModem CLS||CRLF
  1206.     Exit 0
  1207.  
  1208. Redraw_Screen:
  1209.  
  1210.     Arg mode
  1211.  
  1212.     If mode = 0 Then SendModem CLS||"6HStar Trek - The Final Frontier1H"
  1213.     Else SendModem "HC"
  1214.  
  1215.     If ibm = 1 Then Do
  1216.         SendModem "ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸"
  1217.         Do I = 0 To 11
  1218.             SendModem ""||I + 5||";11H³C³C³"
  1219.         End
  1220.     End
  1221.     Else SendModem "==========================================================="
  1222.  
  1223.     If ibm = 1 Then SendModem "11HÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;"
  1224.     Else SendModem "11H==========================================================="
  1225.  
  1226.     SendModem "9HStardate:9HEnergy:9HQuadrant:9HSector:49HCondition:49HShields:49HKlingons:49HScore:"
  1227.  
  1228.     Return
  1229.  
  1230. Display_Scores:
  1231.  
  1232.     SendModem CLS||CRLF||"Top Ten Players"||CRLF||Left(bar.ibm, 45)||""||CRLF
  1233.  
  1234.     Do I = 1 To 10
  1235.         If highscore.I = 0 Then Iterate
  1236.         SendModem highname.I||""||45 - Length(highname.I) - Length(highscore.I)||"C"||highscore.I||CRLF
  1237.     End
  1238.  
  1239.     SendModem CRLF
  1240.  
  1241.     Call Hit_Return
  1242.  
  1243.     SendModem CLS
  1244.  
  1245.     Return
  1246.  
  1247. Redraw_Menu:
  1248.  
  1249.     SendModem CLS||"6HStar Trek - The Final Frontier1H"||Left(bar.ibm, 40)||"8H(1)  Play Star Trek8H(2)  Load Saved Game28H(3)  Instructions28H(4)  Top Ten Players28H(5)  Preferences28H(Q)  Quit to Previous Menu21H"||Left(bar.ibm, 40)||""
  1250.     Return
  1251.  
  1252. Preferences:
  1253.  
  1254.     SendModem CLS||CRLF
  1255.  
  1256.     ibm = GetYesNo(ln, "CDoes your terminal support IBM characters?", 0, 1)
  1257.  
  1258.     SendModem CRLF||CRLF
  1259.  
  1260.     bounce = GetYesNo(ln, "CBounce the screen when the Enterprise is damaged?", 0, 1)
  1261.  
  1262.     Call Save_Preferences
  1263.  
  1264.     Return
  1265.  
  1266. Load_Preferences:
  1267.  
  1268.     LockCarrier
  1269.  
  1270.     If ~Open(fnn, "Doors:StarTrek/_"||uname||".dat", "R") Then UnLockCarrier
  1271.     Else Do
  1272.         inn = Readln(fnn)
  1273.  
  1274.         Parse Var inn ibm " " bounce " "
  1275.  
  1276.         Close(fnn)
  1277.  
  1278.         UnLockCarrier
  1279.     End
  1280.  
  1281.     Return
  1282.  
  1283. Save_Preferences:
  1284.  
  1285.     LockCarrier
  1286.  
  1287.     If ~Open(fnn, "Doors:StarTrek/_"||uname||".dat", "A") Then If ~Open(fnn, "Doors:StarTrek/_"||uname||".dat", "W") Then Do
  1288.         UnLockCarrier
  1289.         Return
  1290.     End
  1291.  
  1292.     Seek(fnn, 0, "Begin")
  1293.  
  1294.     Writeln(fnn, ibm bounce||Left("", 60)) /* length 64 bytes */
  1295.  
  1296.     Close(fnn)
  1297.  
  1298.     UnLockCarrier
  1299.  
  1300.     Return
  1301.  
  1302. IoErr:
  1303. Syntax:
  1304. Error:
  1305.  
  1306.     SendModem CRLF||CRLF||"Error: "||RC||" - "||ERRORTEXT(RC)||" @ "||SIGL||CRLF||CRLF
  1307.     Exit 0
  1308.